import {getProjectRoutes} from "@/api/project";

import user from "./user";

const state = {
  routes: []
}

const mutations = {
  SET_ROUTES: (state, routes) => {
    state.routes = routes
  }
}

const actions = {
  getProjectRouteList({commit}) {
    return new Promise((resolve, reject) => {
      getProjectRoutes({corpId: user.state.corpinfo.corpid}).then(response => {
        commit('SET_ROUTES', response)
        resolve(response)
      }).catch(err => {
        reject(err)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
